package C009;

/**
 * ClassName: DoubleLinkedReverse
 * Package: C007
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/11/29 11:43
 * @Version 1.0
 * @Since 1.0
 */
public class DoubleLinkedReverse {
    public static void main(String[] args) {


    }

    static class DoubleListNode {
        int val;
        DoubleListNode last;
        DoubleListNode next;
    }

    public static DoubleListNode reverse(DoubleListNode head) {
        DoubleListNode pre = null;
        DoubleListNode next;
        while(head != null) {
            next = head.next;
            head.next = pre;
            head.last = next;
            pre = head;
            head = next;
        }

        return pre;
    }
}
